<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String newsid=request.getParameter("id"); 
String fr=request.getParameter("fr"); 

%>
<script type="text/javascript">
<!--

//-->
</script>
<style>
<!--
 	.btn_newsadd{
 		margin-left:50px; 
 	}
-->
</style>
<link href="css/style.css" rel="stylesheet" type="text/css" /> 
<link href="<%=path %>/resources/date/bootstrap-datetimepicker.min.css" rel="stylesheet" type="text/css" /> 
<link rel="stylesheet" type="text/css" href="<%=path %>/css/bootstrap.min.css" />
<script type="text/javascript" src="<%=path %>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%=path %>/js/bootstrap.js"></script>
<script type="text/javascript" src="<%=path %>/resources/date/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="<%=path %>/resources/date/bootstrap-datetimepicker.zh-CN.js"></script>
<script type="text/javascript" src="<%=path %>/js/resources/common.js"></script>

    <jsp:include page="common.jsp"></jsp:include>
	<div class="place">
    <span>位置：</span>
    <ul class="placeul">
    <li>系统设置</li>
    <li><span id="lujing">导航菜单添加</span></li> 
    </ul>
    </div>
    
    <div class="formbody">
    
    <div class="formtitle"><span>基本信息</span></div>
    
    <ul class="forminfo">
    <li><label>菜单标题</label><input name="name" id="name" type="text" class="dfinput" style="width:60%;"/><i>*标题不能超过20个字符</i></li>
    
    <div class="formtitle"><span>链接页面信息</span></div>
     
    <li> 
    
    	<form enctype="multipart/form-data" target='frameFile' action="../../navMenuAction_saveFile.action" method="post" id="fileform">
	    	<input type="file" accept=".jsp,.html,.htm" name="file" id="file" onChange="showMsg()"/>
    	</form>
    </li>
    
    <li><label>&nbsp;</label>
    	<input name="" id="news_save" type="button" class="btn btn-primary btn_newsadd" value="确认保存"/>
    	<input name="" id="news_reset" type="button" class="btn btn-primary btn_newsadd" value="重置"/>
    </li>
    </ul>
    
    	<!-- update information end -->
	<iframe id='frameFile' name='frameFile' style='display: none;'></iframe>
    
    
    </div>
    
 <script type="text/javascript" >
 
	 var path='<%=basePath%>';
	 var pid='<%=newsid%>';
	 var fr='<%=fr%>';
	 
 
 $(function(){
 });
 
 function showMsg(){
	 
	/*  alert("文件上传成功"); */
 }
 
 $("#news_save").unbind("click").bind("click",function(){
	 
	 if(validField()){
			 $("#fileform").submit();
		 $.post(path+"navMenuAction_save.action",{
			 name:$("#name").val(),
			 toHref:"pages/font/up/"+$("#file").val().split("\\")[$("#file").val().split("\\").length-1],
			 sortNo:$("#sortNo").val()
		 },function(res){
			 res=eval('('+res+')');
			 if(res.rescode=='100'){
				 alert("数据保存成功"); 
				 window.location.href="navmenulist.jsp";
			 }
		 });
	 }
 });
 
 function validField(){
	 var v=$("input[name=name]").val();
	 if(!v){
		 showWarnMsg("菜单标题不能为空");
		 return false;
	 }
	 if(v.length>20){
		 showWarnMsg("菜单标题不能大于20个字符");
		 return false;
	 }
		
	 if(!$("#file").val()){
		showWarnMsg("菜单链接页面不能为空");
		return false;
	 }
	 return true;
 }
 
 $("#news_reset").click(function(){ 
		/*jquery 没有reset 方法，使用dom 的，reset 不能重置 textarea，手动重置 textarea */
		$("input[type=text]").val('');
	});
 
 
 </script>